<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="120px">
      <el-form-item label="模型名称" prop="modelName">
        <el-input
            v-model="queryParams.modelName"
            placeholder="请输入模型名称"
            clearable
            @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="省" prop="province">
        <el-select v-model="queryParams.province" placeholder="请选择省" @change="chooseProvince" clearable>
          <el-option
              v-for="item in provinceData"
              :key="item.id"
              :label="item.name"
              :value="item.id">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="市" prop="city">
        <el-select v-model="queryParams.city" placeholder="请选择市" @change="chooseCity" clearable>
          <el-option
              v-for="item in cityData"
              :key="item.id"
              :label="item.name"
              :value="item.id">
          </el-option>
        </el-select>
      </el-form-item>
      <!--<el-form-item label="区/县" prop="areaId">
        <el-select v-model="queryParams.areaId" placeholder="请选择区/县" clearable>
           <el-option
                v-for="item in areaData"
                :key="item.id"
                :label="item.name"
                :value="item.id">
            </el-option>
        </el-select>
      </el-form-item>-->
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button plain icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <!--<el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="Plus"
          @click="handleAdd"
        >新增</el-button>
      </el-col>-->
      <!--<el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="Edit"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:difference:edit']"
        >修改</el-button>
      </el-col>-->
      <!--<el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="Delete"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:difference:remove']"
        >删除</el-button>
      </el-col>-->
      <!--<el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="Download"
          @click="handleExport"
          v-hasPermi="['system:difference:export']"
        >导出</el-button>
      </el-col>-->
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="casualtiesList" stripe>
      <!--<el-table-column type="selection" width="55" align="center" />-->
      <el-table-column label="模型名称" align="center" prop="modelName" >
        <template #default="scope">
          <el-button type="text" @click="edit(scope.row)">{{
              scope.row.modelName
            }}</el-button>
        </template>
      </el-table-column>
      <el-table-column label="省" align="center" prop="province" />
      <el-table-column label="市" align="center" prop="city" />


      <el-table-column label="是否默认" align="center" prop="isDefault">
        <template #default="scope">
          <span v-if="scope.row.isDefault=='0'">否</span>
          <span v-if="scope.row.isDefault=='1'">是</span>
        </template>
      </el-table-column>
      <el-table-column label="维护人" align="center" prop="createUserName" />
      <el-table-column label="维护人所属单位" align="center" prop="orgName" />

      <!--<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button
            type="text"
            @click="handleDelete(scope.row)"
						v-if="scope.row.taskStatus!=2 && scope.row.flag==2"
          >删除</el-button>
        </template>
      </el-table-column>-->
    </el-table>

    <pagination
        v-show="total>0"
        :total="total"
        v-model:page="queryParams.page"
        v-model:limit="queryParams.rows"
        @pagination="getList"
    />

    <!-- 添加或修改区县致死性差异性对话框 -->
    <el-dialog :title="title" v-model="open" width="850px" append-to-body>
      <el-form ref="economicRef" :model="form" :rules="rules" label-width="120px">
        <p class="dialogTitle">{{title}}</p>
        <el-row>
          <el-col :span="12">
            <el-form-item label="模型名称" prop="modelName" v-if="isCopy">
              {{form.modelName}}
            </el-form-item>
            <el-form-item label="模型名称" prop="modelName" v-else>
              <el-input v-model="form.modelName" placeholder="请输入模型名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否默认" prop="" v-if="isCopy">
              {{form.isDefault=='0'?'否':'是'}}
            </el-form-item>
            <el-form-item label="是否默认" prop="" v-else>
              <el-select v-model="form.isDefault" disabled style="width: 100%;">
                <el-option
                    v-for="item in [
	                  { value: '0', label: '否' },
	                  { value: '1', label: '是' },
	                ]"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="地区" prop="" v-if="isCopy||isEditDefault">
              {{form.province}} - {{form.city}}
            </el-form-item>
            <el-form-item label="地区" prop="" v-else>

              <el-form-item label="省" prop="provinceId" label-width="50px">
                <el-select v-model="form.provinceId" :disabled="isDisableds" placeholder="请输入省" @change="chooseFormProvince"  style="width: 160px;">
                  <el-option
                      v-for="item in provinceFormData"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-col :span="16">
                <el-form-item label="市" prop="" label-width="50px">
                  <el-radio-group v-model="radio" @change="chooseRadio">
                    <el-radio label="1">全部</el-radio>
                    <el-radio label="2">
                      <el-select v-model="form.cityId" placeholder="请输入市" multiple collapse-tags :disabled="isCityEdit" style="width: 200px;">
                        <el-option
                            v-for="item in cityFormData"
                            :key="item.id"
                            :label="item.name"
                            :value="item.id">
                        </el-option>
                      </el-select>
                    </el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>



            </el-form-item>
          </el-col>

        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="维护人" prop="">
              {{form.createUserName}}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="维护人单位" prop="">
              {{form.orgName}}
            </el-form-item>
          </el-col>

        </el-row>


        <el-row>
          <el-col :span="6" class="tab-title">
            建筑物经济损失评估模型
          </el-col>
        </el-row>
        <el-row style="margin-bottom: 20px;">
          <el-col :span="6" :offset="1">
            （1）建筑物结构经济损失
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12" :offset="6" v-if="isCopy">
						<span style="font-size: 16px;font-weight: bold;font-style: italic;"> E<sub>f</sub> = ∑<sub style="position: absolute;top: 20px;margin-left: -6px;">s</sub> ∑<sub style="position: absolute;top: 20px;margin-left: -6px;">j</sub>
							(S<sub>s</sub><sub>j</sub> * P<sub>s</sub> * L<sub>s</sub><sub>j</sub>) * δI / 10000
						</span><br/><br/>
            式中：<br/>
            E<sub>f</sub> --表示建筑物结构经济损失；<br/>
            S<sub>s</sub><sub>j</sub> --表示建筑物破坏情况明细，公里格网s类建筑物j破坏等级的面积；<br/>
            P<sub>s</sub> --表示建筑物每平方米造价，公里格网s类建筑物的每平方米造价；<br/>
            L<sub>s</sub><sub>j</sub> --表示建筑物损失比矩阵，s类建筑物在j破坏等级下的损失比；<br/>
            δI --表示评估调整参数。<br/>

          </el-col>
          <el-col :span="12" :offset="6" v-else>
						<span style="font-size: 16px;font-weight: bold;font-style: italic;"> E<sub>f</sub> = ∑<sub style="position: absolute;top: 20px;margin-left: -6px;">s</sub> ∑<sub style="position: absolute;top: 20px;margin-left: -6px;">j</sub>
							(S<sub>s</sub><sub>j</sub> * P<sub>s</sub> * L<sub>s</sub><sub>j</sub>) * 
							<el-form-item prop="structureLossess" style="display: inline-block;" label-width="0px">
								<el-input v-model="form.structureLossess" placeholder="" style="width: 100px;" />
							</el-form-item>
							 / 10000
						</span><br/><br/>
            式中：<br/>
            E<sub>f</sub> --表示建筑物结构经济损失；<br/>
            S<sub>s</sub><sub>j</sub> --表示建筑物破坏情况明细，公里格网s类建筑物j破坏等级的面积；<br/>
            P<sub>s</sub> --表示建筑物每平方米造价，公里格网s类建筑物的每平方米造价；<br/>
            L<sub>s</sub><sub>j</sub> --表示建筑物损失比矩阵，s类建筑物在j破坏等级下的损失比；<br/>
            δI --表示评估调整参数。<br/>

          </el-col>
        </el-row>
        <el-row style="margin: 20px 0;">
          <el-col :span="6" :offset="1">
            （2）建筑物室内财产经济损失
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="18" :offset="4" v-if="isCopy">
						<span style="font-size: 16px;font-weight: bold;font-style: italic;"> E<sub>e</sub> = ∑<sub style="position: absolute;top: 20px;margin-left: -6px;">s</sub> ∑<sub style="position: absolute;top: 20px;margin-left: -6px;">j</sub>
							(S<sub>s</sub><sub>j</sub> * P<sub>e</sub> * L<sub>s</sub><sub>j</sub>) * δI / 10000
						</span><br/><br/>
            式中：<br/>
            E<sub>e</sub> --表示建筑物结构经济损失；<br/>
            S<sub>s</sub><sub>j</sub> --表示建筑物破坏情况明细，公里格网s类建筑物j破坏等级的面积；<br/>
            P<sub>e</sub> --表示建筑物室内财产；<br/>
            L<sub>s</sub><sub>j</sub> --表示建筑物损失比矩阵，s类建筑物在j破坏等级下的损失比；<br/>
            δI --表示评估调整参数。<br/>
            <div style="margin-top:10px;line-height: 30px;">
              <table align="center" style="width: 100%;border-collapse: collapse;">
                <caption>建筑物损失比矩阵样例：</caption>
                <tr>
                  <td id="lineTd">
                    <span style="float:left;margin-top:20px;">结构类型</span>
                    <span style="float:right;margin-top:0px;">破坏程度</span>
                  </td>
                  <td style="width: 100px;" align="center" valign="middle">基本完好</td>
                  <td style="width: 100px;" align="center" valign="middle">轻微破坏</td>
                  <td style="width: 100px;" align="center" valign="middle">中等破坏</td>
                  <td style="width: 100px;" align="center" valign="middle">严重破坏</td>
                  <td style="width: 100px;" align="center" valign="middle">毁坏</td>
                </tr>

                <tr>

                </tr>
                <tr>
                  <td style="width: 150px;" align="center" valign="middle">高层建筑</td>
                  <td align="center" valign="middle">{{form.highBasicIntact}}</td>
                  <td align="center" valign="middle">{{form.highSlightDamage}}</td>
                  <td align="center" valign="middle">{{form.highMidDamage}}</td>
                  <td align="center" valign="middle">{{form.highBadDamage}}</td>
                  <td align="center" valign="middle">{{form.highDestory}}</td>

                </tr>
                <tr>
                  <td align="center" valign="middle">钢结构</td>
                  <td align="center" valign="middle">{{form.steelBasicIntact}}</td>
                  <td align="center" valign="middle">{{form.steelSlightIntact}}</td>
                  <td align="center" valign="middle">{{form.steelMidIntact}}</td>
                  <td align="center" valign="middle">{{form.steelBadIntact}}</td>
                  <td align="center" valign="middle">{{form.steelDestory}}</td>

                </tr>
                <tr>
                  <td align="center" valign="middle">多层钢筋混凝土结构</td>
                  <td align="center" valign="middle">{{form.multipleBasicIntact}}</td>
                  <td align="center" valign="middle">{{form.multipleSlightIntact}}</td>
                  <td align="center" valign="middle">{{form.multipleMidIntact}}</td>
                  <td align="center" valign="middle">{{form.multipleBadIntact}}</td>
                  <td align="center" valign="middle">{{form.multipleDestory}}</td>

                </tr>
                <tr>
                  <td align="center" valign="middle">砖混结构</td>
                  <td align="center" valign="middle">{{form.brickConcreteBasicIntact}}</td>
                  <td align="center" valign="middle">{{form.brickConcreteSlightIntact}}</td>
                  <td align="center" valign="middle">{{form.brickConcreteMidIntact}}</td>
                  <td align="center" valign="middle">{{form.brickConcreteBadIntact}}</td>
                  <td align="center" valign="middle">{{form.brickConcreteDestory}}</td>

                </tr>
                <tr>
                  <td align="center" valign="middle">砖木结构</td>
                  <td align="center" valign="middle">{{form.brickWoodBasicIntact}}</td>
                  <td align="center" valign="middle">{{form.brickWoodSlightIntact}}</td>
                  <td align="center" valign="middle">{{form.brickWoodMidIntact}}</td>
                  <td align="center" valign="middle">{{form.brickWoodBadIntact}}</td>
                  <td align="center" valign="middle">{{form.brickWoodDestory}}</td>

                </tr>

                <tr>
                  <td align="center" valign="middle">土结构</td>
                  <td align="center" valign="middle">{{form.soilBasicIntact}}</td>
                  <td align="center" valign="middle">{{form.soilSlightIntact}}</td>
                  <td align="center" valign="middle">{{form.soilMidIntact}}</td>
                  <td align="center" valign="middle">{{form.soilBadIntact}}</td>
                  <td align="center" valign="middle">{{form.soilDestory}}</td>

                </tr>
                <tr>
                  <td align="center" valign="middle">木结构</td>
                  <td align="center" valign="middle">{{form.woodBasicIntact}}</td>
                  <td align="center" valign="middle">{{form.woodSlightIntact}}</td>
                  <td align="center" valign="middle">{{form.woodMidIntact}}</td>
                  <td align="center" valign="middle">{{form.woodBadIntact}}</td>
                  <td align="center" valign="middle">{{form.woodDestory}}</td>
                </tr>
                <tr>
                  <td align="center" valign="middle">石结构</td>
                  <td align="center" valign="middle">{{form.stoneBasicIntact}}</td>
                  <td align="center" valign="middle">{{form.stoneSlightIntact}}</td>
                  <td align="center" valign="middle">{{form.stoneMidIntact}}</td>
                  <td align="center" valign="middle">{{form.stoneBadIntact}}</td>
                  <td align="center" valign="middle">{{form.stoneDestory}}</td>
                </tr>
                <tr>
                  <td align="center" valign="middle">其他结构</td>
                  <td align="center" valign="middle">{{form.otherBasicIntact}}</td>
                  <td align="center" valign="middle">{{form.otherSlightIntact}}</td>
                  <td align="center" valign="middle">{{form.otherMidIntact}}</td>
                  <td align="center" valign="middle">{{form.otherBadIntact}}</td>
                  <td align="center" valign="middle">{{form.otherDestory}}</td>
                </tr>

              </table>
            </div>


          </el-col>
          <el-col :span="18" :offset="4" v-else>
						<span style="font-size: 16px;font-weight: bold;font-style: italic;"> E<sub>e</sub> = ∑<sub style="position: absolute;top: 20px;margin-left: -6px;">s</sub> ∑<sub style="position: absolute;top: 20px;margin-left: -6px;">j</sub>
							(S<sub>s</sub><sub>j</sub> * P<sub>e</sub> * L<sub>s</sub><sub>j</sub>) * 
							<el-form-item prop="indoorLossess" style="display: inline-block;" label-width="0px">
								<el-input v-model="form.indoorLossess" placeholder="" style="width: 100px;" />
							</el-form-item>
							 / 10000
						</span><br/><br/>
            式中：<br/>
            E<sub>f</sub> --表示建筑物结构经济损失；<br/>
            S<sub>s</sub><sub>j</sub> --表示建筑物破坏情况明细，公里格网s类建筑物j破坏等级的面积；<br/>
            P<sub>e</sub> --表示建筑物室内财产；<br/>
            L<sub>s</sub><sub>j</sub> --表示建筑物损失比矩阵，s类建筑物在j破坏等级下的损失比；<br/>
            δI --表示评估调整参数。<br/>
            <div style="margin-top:10px;line-height: 30px;">
              <table align="center" style="width: 100%;border-collapse: collapse;">
                <caption>建筑物损失比矩阵样例：</caption>
                <tr>
                  <td id="lineTd">
                    <span style="float:left;margin-top:20px;">结构类型</span>
                    <span style="float:right;margin-top:0px;">破坏程度</span>
                  </td>
                  <td style="width: 100px;" align="center" valign="middle">基本完好</td>
                  <td style="width: 100px;" align="center" valign="middle">轻微破坏</td>
                  <td style="width: 100px;" align="center" valign="middle">中等破坏</td>
                  <td style="width: 100px;" align="center" valign="middle">严重破坏</td>
                  <td style="width: 100px;" align="center" valign="middle">毁坏</td>
                </tr>

                <tr>

                </tr>
                <tr>
                  <td style="width: 150px;" align="center" valign="middle">高层建筑</td>
                  <td align="center" valign="middle">
                    <el-form-item prop="highBasicIntact" label-width="0px">
                      <el-input v-model="form.highBasicIntact" placeholder="[0,1]" />
                    </el-form-item>

                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="highSlightDamage" label-width="0px">
                      <el-input v-model="form.highSlightDamage" placeholder="[0,1]" />
                    </el-form-item>
                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="highMidDamage" label-width="0px">
                      <el-input v-model="form.highMidDamage" placeholder="[0,1]" />
                    </el-form-item>
                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="highBadDamage" label-width="0px">
                      <el-input v-model="form.highBadDamage" placeholder="[0,1]" />
                    </el-form-item>
                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="highDestory" label-width="0px">
                      <el-input v-model="form.highDestory" placeholder="[0,1]" />
                    </el-form-item>
                  </td>

                </tr>
                <tr>
                  <td align="center" valign="middle">钢结构</td>
                  <td align="center" valign="middle">
                    <el-form-item prop="steelBasicIntact" label-width="0px">
                      <el-input v-model="form.steelBasicIntact" placeholder="[0,1]" />
                    </el-form-item>
                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="steelSlightIntact" label-width="0px">
                      <el-input v-model="form.steelSlightIntact" placeholder="[0,1]" />
                    </el-form-item>
                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="steelMidIntact" label-width="0px">
                      <el-input v-model="form.steelMidIntact" placeholder="[0,1]" />
                    </el-form-item>
                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="steelBadIntact" label-width="0px">
                      <el-input v-model="form.steelBadIntact" placeholder="[0,1]" />
                    </el-form-item>

                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="steelDestory" label-width="0px">
                      <el-input v-model="form.steelDestory" placeholder="[0,1]" />
                    </el-form-item>
                  </td>

                </tr>
                <tr>
                  <td align="center" valign="middle">多层钢筋混凝土结构</td>
                  <td align="center" valign="middle">
                    <el-form-item prop="multipleBasicIntact" label-width="0px">
                      <el-input v-model="form.multipleBasicIntact" placeholder="[0,1]" />
                    </el-form-item>
                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="multipleSlightIntact" label-width="0px">
                      <el-input v-model="form.multipleSlightIntact" placeholder="[0,1]" />
                    </el-form-item>
                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="multipleMidIntact" label-width="0px">
                      <el-input v-model="form.multipleMidIntact" placeholder="[0,1]" />
                    </el-form-item>
                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="multipleBadIntact" label-width="0px">
                      <el-input v-model="form.multipleBadIntact" placeholder="[0,1]" />
                    </el-form-item>

                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="multipleDestory" label-width="0px">
                      <el-input v-model="form.multipleDestory" placeholder="[0,1]" />
                    </el-form-item>
                  </td>

                </tr>
                <tr>
                  <td align="center" valign="middle">砖混结构</td>
                  <td align="center" valign="middle">
                    <el-form-item prop="brickConcreteBasicIntact" label-width="0px">
                      <el-input v-model="form.brickConcreteBasicIntact" placeholder="[0,1]" />
                    </el-form-item>
                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="brickConcreteSlightIntact" label-width="0px">
                      <el-input v-model="form.brickConcreteSlightIntact" placeholder="[0,1]" />
                    </el-form-item>

                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="brickConcreteMidIntact" label-width="0px">
                      <el-input v-model="form.brickConcreteMidIntact" placeholder="[0,1]" />
                    </el-form-item>
                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="brickConcreteBadIntact" label-width="0px">
                      <el-input v-model="form.brickConcreteBadIntact" placeholder="[0,1]" />
                    </el-form-item>
                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="brickConcreteDestory" label-width="0px">
                      <el-input v-model="form.brickConcreteDestory" placeholder="[0,1]" />
                    </el-form-item>
                  </td>

                </tr>
                <tr>
                  <td align="center" valign="middle">砖木结构</td>
                  <td align="center" valign="middle">
                    <el-form-item prop="brickWoodBasicIntact" label-width="0px">
                      <el-input v-model="form.brickWoodBasicIntact" placeholder="[0,1]" />
                    </el-form-item>

                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="brickWoodSlightIntact" label-width="0px">
                      <el-input v-model="form.brickWoodSlightIntact" placeholder="[0,1]" />
                    </el-form-item>

                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="brickWoodMidIntact" label-width="0px">
                      <el-input v-model="form.brickWoodMidIntact" placeholder="[0,1]" />
                    </el-form-item>

                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="brickWoodBadIntact" label-width="0px">
                      <el-input v-model="form.brickWoodBadIntact" placeholder="[0,1]" />
                    </el-form-item>

                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="brickWoodDestory" label-width="0px">
                      <el-input v-model="form.brickWoodDestory" placeholder="[0,1]" />
                    </el-form-item>
                  </td>

                </tr>

                <tr>
                  <td align="center" valign="middle">土结构</td>
                  <td align="center" valign="middle">
                    <el-form-item prop="soilBasicIntact" label-width="0px">
                      <el-input v-model="form.soilBasicIntact" placeholder="[0,1]" />
                    </el-form-item>
                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="soilSlightIntact" label-width="0px">
                      <el-input v-model="form.soilSlightIntact" placeholder="[0,1]" />
                    </el-form-item>
                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="soilMidIntact" label-width="0px">
                      <el-input v-model="form.soilMidIntact" placeholder="[0,1]" />
                    </el-form-item>

                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="soilBadIntact" label-width="0px">
                      <el-input v-model="form.soilBadIntact" placeholder="[0,1]" />
                    </el-form-item>

                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="soilDestory" label-width="0px">
                      <el-input v-model="form.soilDestory" placeholder="[0,1]" />
                    </el-form-item>

                  </td>

                </tr>
                <tr>
                  <td align="center" valign="middle">木结构</td>
                  <td align="center" valign="middle">
                    <el-form-item prop="woodBasicIntact" label-width="0px">
                      <el-input v-model="form.woodBasicIntact" placeholder="[0,1]" />
                    </el-form-item>
                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="woodSlightIntact" label-width="0px">
                      <el-input v-model="form.woodSlightIntact" placeholder="[0,1]" />
                    </el-form-item>
                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="woodMidIntact" label-width="0px">
                      <el-input v-model="form.woodMidIntact" placeholder="[0,1]" />
                    </el-form-item>
                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="woodBadIntact" label-width="0px">
                      <el-input v-model="form.woodBadIntact" placeholder="[0,1]" />
                    </el-form-item>

                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="woodDestory" label-width="0px">
                      <el-input v-model="form.woodDestory" placeholder="[0,1]" />
                    </el-form-item>

                  </td>
                </tr>
                <tr>
                  <td align="center" valign="middle">石结构</td>
                  <td align="center" valign="middle">
                    <el-form-item prop="stoneBasicIntact" label-width="0px">
                      <el-input v-model="form.stoneBasicIntact" placeholder="[0,1]" />
                    </el-form-item>

                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="stoneSlightIntact" label-width="0px">
                      <el-input v-model="form.stoneSlightIntact" placeholder="[0,1]" />
                    </el-form-item>

                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="stoneMidIntact" label-width="0px">
                      <el-input v-model="form.stoneMidIntact" placeholder="[0,1]" />
                    </el-form-item>

                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="stoneBadIntact" label-width="0px">
                      <el-input v-model="form.stoneBadIntact" placeholder="[0,1]" />
                    </el-form-item>

                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="stoneDestory" label-width="0px">
                      <el-input v-model="form.stoneDestory" placeholder="[0,1]" />
                    </el-form-item>
                  </td>
                </tr>
                <tr>
                  <td align="center" valign="middle">其他结构</td>
                  <td align="center" valign="middle">
                    <el-form-item prop="otherBasicIntact" label-width="0px">
                      <el-input v-model="form.otherBasicIntact" placeholder="[0,1]" />
                    </el-form-item>
                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="otherSlightIntact" label-width="0px">
                      <el-input v-model="form.otherSlightIntact" placeholder="[0,1]" />
                    </el-form-item>
                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="otherMidIntact" label-width="0px">
                      <el-input v-model="form.otherMidIntact" placeholder="[0,1]" />
                    </el-form-item>

                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="otherBadIntact" label-width="0px">
                      <el-input v-model="form.otherBadIntact" placeholder="[0,1]" />
                    </el-form-item>

                  </td>
                  <td align="center" valign="middle">
                    <el-form-item prop="otherDestory" label-width="0px">
                      <el-input v-model="form.otherDestory" placeholder="[0,1]" />
                    </el-form-item>
                  </td>
                </tr>

              </table>
            </div>

          </el-col>
        </el-row>
        <el-row style="margin: 20px 0;">
          <el-col :span="6" :offset="1">
            （3）建筑物直接经济损失
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12" :offset="6">
            <span style="font-size: 16px;font-weight: bold;font-style: italic;">E<sub>b</sub> = E<sub>f</sub> + E<sub>e</sub></span><br/><br/>
            E<sub>b</sub>为建筑物直接经济损失，E<sub>f</sub>为建筑物结构经济损失，E<sub>e</sub>为建筑物室内财产经济损失。<br/>

          </el-col>
        </el-row>
        <el-row style="margin-top: 30px;">
          <el-col :span="6" class="tab-title">
            生命线经济损失评估
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12" :offset="6" v-if="isCopy">
            <span style="font-size: 16px;font-weight: bold;font-style: italic;"> L<sub>s</sub> = <span style="position: absolute;top: -15px;">E<sub>b</sub></span>——<span style="position: absolute;top: 12px;margin-left: -30px;">B<sub>m</sub></span> * L<sub>m</sub></span><br/><br/>
            L<sub>s</sub>为公里格网生命线经济损失，E<sub>b</sub>为公里格网建筑物直接经济损失，B<sub>m</sub>为建筑物经济损失在总经济损失中所占百分比，L<sub>m</sub>为生命线经济损失在总经济损失中所占百分比。<br/>

          </el-col>
          <el-col :span="12" :offset="6" v-else>
						<span style="font-size: 16px;font-weight: bold;font-style: italic;"> L<sub>s</sub> = <span style="position: absolute;top: -15px;margin-left: 15px;">E<sub>b</sub></span>————
						<span style="position: absolute;top: 22px;margin-left: -70px;">
							<el-form-item prop="lifeRatio1" style="display: inline-block;" label-width="0px">
								<el-input v-model="form.lifeRatio1" placeholder="百分比" style="width: 70px;" />
							</el-form-item>
						</span> * 
						<el-form-item prop="lifeRatio2" style="display: inline-block;" label-width="0px">
							<el-input v-model="form.lifeRatio2" placeholder="百分比" style="width: 70px;" />
						</el-form-item>	
						</span><br/><br/><br/>
            L<sub>s</sub>为公里格网生命线经济损失，E<sub>b</sub>为公里格网建筑物直接经济损失，B<sub>m</sub>为建筑物经济损失在总经济损失中所占百分比，L<sub>m</sub>为生命线经济损失在总经济损失中所占百分比。<br/>

          </el-col>
        </el-row>

        <el-row style="margin-top: 30px;">
          <el-col :span="6" class="tab-title">
            其他经济损失评估
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12" :offset="6" v-if="isCopy">
            <span style="font-size: 16px;font-weight: bold;font-style: italic;"> O<sub>s</sub> = <span style="position: absolute;top: -15px;">E<sub>b</sub></span>——<span style="position: absolute;top: 12px;margin-left: -30px;">B<sub>m</sub></span> * O<sub>m</sub></span><br/><br/>
            O<sub>s</sub>为公里格网生命线经济损失，E<sub>b</sub>为公里格网建筑物直接经济损失，B<sub>m</sub>为建筑物经济损失在总经济损失中所占百分比，O<sub>m</sub>为其他经济损失在总经济损失中所占百分比。<br/>

          </el-col>
          <el-col :span="12" :offset="6" v-else>
						<span style="font-size: 16px;font-weight: bold;font-style: italic;"> O<sub>s</sub> = <span style="position: absolute;top: -15px;margin-left: 15px;">E<sub>b</sub></span>————
						<span style="position: absolute;top: 22px;margin-left: -70px;">
							<el-form-item prop="otherRatio1" style="display: inline-block;" label-width="0px">
								<el-input v-model="form.otherRatio1" placeholder="百分比" style="width: 70px;" />
							</el-form-item>
						</span> * 
						<el-form-item prop="otherRatio2" style="display: inline-block;" label-width="0px">
							<el-input v-model="form.otherRatio2" placeholder="百分比" style="width: 70px;" />
						</el-form-item>
						</span><br/><br/><br/>
            O<sub>s</sub>为公里格网生命线经济损失，E<sub>b</sub>为公里格网建筑物直接经济损失，B<sub>m</sub>为建筑物经济损失在总经济损失中所占百分比，O<sub>m</sub>为其他经济损失在总经济损失中所占百分比。<br/>

          </el-col>
        </el-row>

        <el-row style="margin-top: 30px;">
          <el-col :span="6" class="tab-title">
            直接经济损失评估
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12" :offset="6">
            <span style="font-size: 16px;font-weight: bold;font-style: italic;">E = E<sub>b</sub> + L<sub>s</sub> + O<sub>s</sub></span><br/><br/>
            E为直接经济损失，E<sub>b</sub>为建筑物直接经济损失，L<sub>s</sub>为公里格网生命线经济损失，O<sub>s</sub>为公里格网其他经济损失。<br/>

          </el-col>
        </el-row>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="copyForm" v-if="isCopy">复 制</el-button>
          <el-button type="primary" @click="saveForm" v-if="!isCopy&&Default=='1'" :disabled="isDisabled">保 存</el-button>
          <el-button type="primary" @click="editForm" v-if="!isCopy&&Default=='0'" :disabled="isDisabled">保 存</el-button>
          <el-button type="primary" @click="delForm" v-if="!isCopy&&Default=='0'">删 除</el-button>
          <el-button plain @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import { listEconomic, getModelEconomic, getModelEconomicForCopy, delEconomic, addEconomic, updateEconomic } from "@/api/modelmanage/economic";
import { getProvince, getProvince2, getChildArea} from "@/api/system/division";
import { getLanderRoles, getLanderProvince } from "@/api/basedatamanage/common.js"
import { getUserId, setUserId } from '@/utils/auth'
import { isDecimal } from '@/utils/validate'
import useUserStore from '@/store/modules/user'

const userStore = useUserStore();
const { proxy } = getCurrentInstance();

const casualtiesList = ref([]);
const isEdit = ref(false);
const isCopy = ref(true);
const Default = ref("1");
const radio = ref("1");
const isCityEdit = ref(true);
const isEditDefault = ref(true);
const isShow = ref(true);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");
const submitTime = ref("");//提交时间
const provinceData = ref([]);//省
const cityData = ref([]);//市
const areaData = ref([]);//区、县

const provinceFormData = ref([]);//表单省
const cityFormData = ref([]);//表单市
const areaFormData = ref([]);//表单区、县

const isDisabled = ref(false);

//正数字正则
const positiveInteger = (rule, value, callback) => {
  value = String(value)
  if (isNaN(value)|| !value) {
    return callback(new Error());
  }
  var re = /^[0-9]*$/;
  if (!re.test(value)) {
    callback(new Error());
  }else{
    callback();
  }
}
const positive0_1integer = (rule, value, callback) => {
  value = String(value)
  if (isNaN(value)|| !value) {
    return callback(new Error());
  }
  var re = /^(1|0(\.\d{1,2})?)$/;
  if (!re.test(value)) {
    callback(new Error());
  }else{
    callback();
  }
}
const data = reactive({
  form: {},
  queryParams: {
    page: 1,
    rows: 10,
    province: null,
    city: null,

  },
  rules: {
    taskCode: [
      { required: true, message: "任务编号不能为空", trigger: "blur" }
    ],
    modelName: [
      { required: true, message: "模型名称不能为空", trigger: "blur" }
    ],
    province: [
      { required: true, message: "省不能为空", trigger: "blur" }
    ],
    provinceId: [
      { required: true, message: "省不能为空", trigger: "change" }
    ],
    city: [
      { required: true, message: "市不能为空", trigger: "blur" }
    ],
    cityId: [
      { required: true, message: "市不能为空", trigger: "blur" }
    ],
    area: [
      { required: true, message: "区/县不能为空", trigger: "blur" }
    ],
    areaId: [
      { required: true, message: "区/县 不能为空", trigger: "blur" }
    ],
    highBasicIntact:[{ required: true, message: "[0,1]保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    highSlightDamage:[{ required: true, message: "[0,1]保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    highMidDamage:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    highBadDamage:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    highDestory:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    steelBasicIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    steelSlightIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    steelMidIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    steelBadIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    steelDestory:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    multipleBasicIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    multipleSlightIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    multipleMidIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    multipleBadIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    multipleDestory:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    brickConcreteBasicIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    brickConcreteSlightIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    brickConcreteMidIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    brickConcreteBadIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    brickConcreteDestory:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    brickWoodBasicIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    brickWoodSlightIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    brickWoodMidIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    brickWoodBadIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    brickWoodDestory:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    soilBasicIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    soilSlightIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    soilMidIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    soilBadIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    soilDestory:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    woodBasicIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    woodSlightIntact:[{ required: true, message: "[0,1]保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    woodMidIntact:[{ required: true, message: "[0,1]保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    woodBadIntact:[{ required: true, message: "[0,1]保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    woodDestory:[{ required: true, message: "[0,1]保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    stoneBasicIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    stoneSlightIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    stoneMidIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    stoneBadIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    stoneDestory:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    otherBasicIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    otherSlightIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    otherMidIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    otherBadIntact:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
    otherDestory:[{ required: true, message: "[0,1] 保留两位小数", trigger: "blur" , validator: positive0_1integer}],
		structureLossess:[{ required: true, message: "请输入数字", trigger: "blur" , validator: positiveInteger}],
		indoorLossess:[{ required: true, message: "请输入数字", trigger: "blur" , validator: positiveInteger}],
		lifeRatio1:[{ required: true, message: "请输入数字", trigger: "blur" , validator: positiveInteger}],
		lifeRatio2:[{ required: true, message: "请输入数字", trigger: "blur" , validator: positiveInteger}],
		otherRatio1:[{ required: true, message: "请输入数字", trigger: "blur" , validator: positiveInteger}],
		otherRatio2:[{ required: true, message: "请输入数字", trigger: "blur" , validator: positiveInteger}],
  }
});

const { queryParams, form, rules } = toRefs(data);

/** 查询人口伤亡计算模型列表 */
function getList() {
  loading.value = true;
  listEconomic(queryParams.value).then(response => {
    casualtiesList.value = response.data.rows;;
    total.value = response.data.total;
    loading.value = false;
  });
}

/** 获取省列表 */
function getProvinceData() {
  getProvince2().then(response => {
    provinceData.value = response.data;
  });
}

function getProvinceFormData() {
  getProvince().then(response => {
    provinceFormData.value = response.data;
  });
}

function editProvinceFormData(provinceId,cityId) {
  getProvince().then(response => {
    provinceFormData.value = response.data;
  });
  getChildArea(provinceId).then(response => {
    cityFormData.value = response.data;
  });
  getChildArea(cityId).then(response => {
    areaFormData.value = response.data;
  });
}

function chooseRadio(value){
  console.log(value)
  if(value == "2"){
    isCityEdit.value = false

  }else{
    isCityEdit.value = true
    form.value.city = "全部"
    form.value.cityId = ""
  }
}

function chooseProvince(value){
  queryParams.value.city = null;
  queryParams.value.area = null;
  cityData.value = [];
  areaData.value = [];
  getChildArea(value).then(response => {
    cityData.value = response.data;
  });
//	provinceData.value.map(item => {//遍历数据
//		if(item.id == value){
//			if(item.name == "北京市"||item.name == "天津市"||item.name == "上海市"||item.name == "重庆市"){
//		    cityData.value.push(JSON.parse(JSON.stringify(item)));
//			}else{
//				getChildArea(value).then(response => {
//			    cityData.value = response.data;
//				});
//			}
//			return;
//		}
//})
}

function chooseFormProvince(value){
  form.value.city = null;

  cityFormData.value = [];
  areaFormData.value = [];
  getChildArea(value).then(response => {
    cityFormData.value = response.data;
  });
}

function chooseCity(value){
  queryParams.value.areaId = null;
  areaData.value = [];
  getChildArea(value).then(response => {
    areaData.value = response.data;
  });
}

function chooseFormCity(value){

  areaFormData.value = [];
  getChildArea(value).then(response => {
    areaFormData.value = response.data;
  });
}
function chooseTaskName(value){
  taskNameData.value.map(item => {//遍历数据
    if(item.taskName == value){
      form.value.taskCode = item.taskNum;
      console.log(form.value.taskCode)
      return;
    }
  })

}
// 取消按钮
function cancel() {
  open.value = false;
  reset();
}

// 表单重置
function reset() {
  form.value = {
    id: null,
    modelName: null,
    province: null,
    provinceId: null,
    city: null,
    cityId: null,
    areaId: null,

    isDefault: null,


  };
  proxy.resetForm("economicRef");
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.page = 1;

  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  cityData.value = [];
  areaData.value = [];
  proxy.resetForm("queryRef");
  handleQuery();
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.id);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}

//获取当前日期函数
function getNowFormatDate() {
  let date = new Date(),
      seperator1 = '-', //格式分隔符
      year = date.getFullYear(), //获取完整的年份(4位)
      month = date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
      strDate = date.getDate() // 获取当前日(1-31)
  if (month >= 1 && month <= 9) month = '0' + month // 如果月份是个位数，在前面补0
  if (strDate >= 0 && strDate <= 9) strDate = '0' + strDate // 如果日是个位数，在前面补0

  let currentdate = year + seperator1 + month + seperator1 + strDate
  return currentdate
}



/** 查看按钮操作 */
function edit(row) {
  reset();
  const id = row.id
  if(row.isDefault=="1"){
    isCopy.value = true;
    Default.value = "1";
    title.value = "系统默认经济损失计算模型";
  }else{
    isCopy.value = false;
    Default.value = "0";
    title.value = "经济损失计算模型";
  }

  getModelEconomic(id).then(response => {

    form.value = response.data;

    open.value = true;
    if(form.value.city=="全部"){
      radio.value = "1"
      isCityEdit.value = true
    }else{
      radio.value = "2"
      isCityEdit.value = false
    }
    if(form.value.isDefault=="0"){
      isEditDefault.value = true
    }else{
      isEditDefault.value = false
    }

  });
}

/*复制*/
const copyForm = async() => {
   await getModelEconomicForCopy(form.value.id).then(response => {
    form.value = response.data;
    isCopy.value = false;
    form.value.modelName = null;
    form.value.isDefault = "0";
  });
  title.value = "复制经济损失计算模型";
  if(isDisableds.value){
    form.value.provinceId = AdminProvinceId.value;
    chooseFormProvince(form.value.provinceId);
  }
}

/*新增*/
function saveForm() {
  console.log("新增")

  proxy.$refs["economicRef"].validate(valid => {
    if (valid) {
      if(radio.value == "1"){
        form.value.cityId = "全部"
      }else{
        if(form.value.cityId!=null){
          form.value.cityId = JSON.parse(JSON.stringify(form.value.cityId)).join(",")
        }
      }
      form.value.province = form.value.provinceId;
      form.value.city = form.value.cityId;
      isDisabled.value = true;
      addEconomic(form.value).then(response => {
        proxy.$modal.msgSuccess("新增成功");
        open.value = false;
        isDisabled.value = false;
        getList();
      }).catch(err=>{isDisabled.value = false;});
    }
  })

}
/*编辑*/
function editForm() {
  console.log("编辑")
  proxy.$refs["economicRef"].validate(valid => {
    if (valid) {
      isDisabled.value = true;
      updateEconomic(form.value).then(response => {
        if(response.message=="修改失败，只能修改自己创建的模型"){
          isDisabled.value = false;
          proxy.$modal.msgWarning(response.message);
        }else{
          proxy.$modal.msgSuccess(response.message);
          open.value = false;
          isDisabled.value = false;
          getList();
        }
        //proxy.$modal.msgSuccess("修改成功");

      }).catch(err=>{isDisabled.value = false;});
    }
  })

}
/*删除*/
function delForm() {
  console.log("删除")
  const id = form.value.id;
  proxy.$modal.confirm('是否确认删除？').then(function() {
    //return delEconomic(id);
  }).then(() => {
    delEconomic(id).then(response => {
      if(response.message=="删除失败，只能删除自己创建的模型"){
        proxy.$modal.msgWarning(response.message);
      }else{
        proxy.$modal.msgSuccess(response.message);
        open.value = false;
        getList();
      }
    });
  }).catch(() => {});

}
/** 提交按钮 */
function submitForm() {

  proxy.$refs["economicRef"].validate(valid => {
    if (valid) {
      if (form.value.id != null) {
        updateEconomic(form.value).then(response => {
          proxy.$modal.msgSuccess("修改成功");
          open.value = false;
          getList();
        });
      } else {
        addDifference(form.value).then(response => {
          proxy.$modal.msgSuccess("新增成功");
          open.value = false;
          getList();
        });
      }
    }
  });
}

/** 删除按钮操作 */
function handleDelete(row) {
  const ids = row.id || ids.value;
  proxy.$modal.confirm('是否确认删除区县致死性差异性编号为"' + ids + '"的数据项？').then(function() {
    return delDifference(ids);
  }).then(() => {
    getList();
    proxy.$modal.msgSuccess("删除成功");
  }).catch(() => {});
}

// 权限
const isAdmin = async () => {
	let res = await getLanderRoles()
	const { code, data } = res
	if (code == 200) {
		const auth = data.split(',')
		return auth
	} else {
		return Promise.reject(new Error(data))
	}
}
const isDisableds = ref(false);
const AdminProvinceId = ref('');
const getDefaultProvice = async () => {
	try {
		let curAuth = await isAdmin()
    let flag = curAuth.some(item=>item.includes('国家'))
    isDisableds.value = !flag;
		if (isDisableds.value) {
			getLanderProvince().then(res => {
				if (res.code == 200) {  
          AdminProvinceId.value = res.data
				}else{
          AdminProvinceId.value = ''
        }
			})
			getList();
		} else {
			getList()
		}
	} catch (error) {

	}
}
getDefaultProvice()
// getList();
getProvinceData();
getProvinceFormData();
</script>
<style scoped lang="scss">
.tab-title {
  font-size: 16px;
  font-weight: bold;
  border-left: 4px solid var(--el-color-primary);
  font-family: PingFangSC-Medium;
  padding-left: 10px;
  margin-bottom: 20px;
}
#lineTd {
  background: #fff url() no-repeat 100% center;
}
table td{
  border:1px solid #c6c6c6;
}

</style>
